/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import controller.CardapioJpaController;
import java.io.Serializable;
import java.util.List;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Renato
 */
@Entity
@Table(name = "cardapio")
@NamedQueries({@NamedQuery(name = "Cardapio.findAll", query = "SELECT c FROM Cardapio c"), @NamedQuery(name = "Cardapio.findById", query = "SELECT c FROM Cardapio c WHERE c.id = :id"), @NamedQuery(name = "Cardapio.findByProduto", query = "SELECT c FROM Cardapio c WHERE c.produto = :produto"), @NamedQuery(name = "Cardapio.findByPreco", query = "SELECT c FROM Cardapio c WHERE c.preco = :preco"), @NamedQuery(name = "Cardapio.findCardapioSemanal", query = "SELECT c FROM Cardapio c WHERE c.semanal = :semanal")})
public class Cardapio implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "produto")
    private String produto;
    @Lob
    @Column(name = "descricao")
    private String descricao;
    @Basic(optional = false)
    @Column(name = "preco")
    private double preco;
    @ManyToMany(mappedBy = "cardapioCollection", fetch = FetchType.EAGER)
    private Set<Cliente> clienteCollection;
    @ManyToMany(mappedBy = "cardapioCollection", fetch = FetchType.EAGER)
    private List<Ingredientes> ingredientesCollection;
    @ManyToMany(mappedBy = "cardapioCollection", fetch = FetchType.EAGER)
    private Set<Promocao> promocaoCollection;

    @Column(name = "semanal")
    private boolean semanal;

    @Column(name = "dia_semana")
    private String diaSemana;

    public String getDiaSemana() {
        return diaSemana;
    }

    public void setDiaSemana(String diaSemana) {
        this.diaSemana = diaSemana;
    }

    public boolean isSemanal() {
        return semanal;
    }

    public void setSemanal(boolean semanal) {
        this.semanal = semanal;
    }

    public Cardapio() {
    }

    public Cardapio(Integer id) {
        this.id = id;
    }

    public Cardapio(Integer id, String produto, double preco) {
        this.id = id;
        this.produto = produto;
        this.preco = preco;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getProduto() {
        return produto;
    }

    public void setProduto(String produto) {
        this.produto = produto;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public double getPreco() {
        return preco;
    }

    public void setPreco(double preco) {
        this.preco = preco;
    }

    public Set<Cliente> getClienteCollection() {
        return clienteCollection;
    }

    public void setClienteCollection(Set<Cliente> clienteCollection) {
        this.clienteCollection = clienteCollection;
    }

    public List<Ingredientes> getIngredientesCollection() {
        return ingredientesCollection;
    }

    public void setIngredientesCollection(List<Ingredientes> ingredientesCollection) {
        this.ingredientesCollection = ingredientesCollection;
    }

    public Set<Promocao> getPromocaoCollection() {
        return promocaoCollection;
    }

    public void setPromocaoCollection(Set<Promocao> promocaoCollection) {
        this.promocaoCollection = promocaoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Object)) {
            return false;
        }
        Cardapio other = new Cardapio();
        CardapioJpaController aux = new CardapioJpaController();
        other = aux.findCardapio(id);
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Cardapio[id=" + id + "]";
    }
}
